//用于显示bug详情的TabPanel
var testProjectBugTabPanel = Ext.create('Ext.tab.Panel', {
    defaults: {
        layout: 'fit'
    },
    items: [{
        title: '详细信息',
        itemId: 'detailForm',
        items: [testProjectBugDetailForm]
    }, {
        title: 'Bug附件',
        itemId: 'attachedList',
        items: [testProjectBugAttachedGrid]
    }],
    dockedItems: [{
        xtype: 'toolbar',
        dock: 'bottom',
        itemId: 'dockedItems',
        ui: 'footer',
        items: [{xtype: 'component', flex: 1},
            {
                xtype: 'numberfield',
                hidden: true,//默认隐藏，只有老师的界面才会显示
                labelWidth: 30,
                fieldLabel: '评分',
                allowBlank: false,
                itemId: 'grade',
                value: 0,
                maxValue: 100,
                minValue: 0
            }, {
                xtype: 'button',
                hidden: true,//默认隐藏，只有老师的界面才会显示
                itemId: 'gradeButton',
                width: 70,
                text: '确认',
                listeners: [{
                    click: function () {
                        var grade = testProjectBugTabPanel.down('#grade').getValue();
                        gradeCopyItem(3, testProjectBugTabPanel.bugId, grade);
                    }
                }]
            }, {
                xtype: 'button',
                width: 70,
                text: '返回',
                itemId: 'backButton',
                listeners: [{
                    click: function () {
                        testProjectBugBackClick();
                    }
                }]
            }, {
                xtype: 'button',
                width: 70,
                text: '保存',
                itemId: 'saveButton',
                listeners: [{
                    click: function () {
                        testProjectBugSave();
                    }
                }]
            }]
    }]
    // buttons: [{
    //     text: '返回',
    //     itemId: 'backButton',
    //     listeners: [{
    //         click: function () {
    //             testProjectBugBackClick();
    //         }
    //     }]
    // }, {
    //     text: '保存',
    //     itemId: 'saveButton',
    //     listeners: [{
    //         click: function () {
    //             testProjectBugSave();
    //         }
    //     }]
    // }]
});

//用于显示bug关联的测试需求的TreeGrid
var testProjectBugChooseTrqTreePanel = Ext.create('Ext.tree.Panel', {
    store: testProjectBugChooseTrqTreePanelStore,
    rootVisible: false,
    useArrows: true,// 是否用箭头
    header: false,
    listeners: {
        beforeitemexpand: function (node, eOpts) {
            if (node.data.id != 'root')
                bugGetTrqChildren(node);
        },
        itemdblclick: function (view, record, item, index, e, eOpts) {
            if (!record.data.leaf)
                Ext.Msg.alert("错误", "请选择叶子节点！");
            else {
                testProjectBugDetailForm.down('#toTrq').setValue(getItemInTreePath(testProjectBugChooseTrqTreePanelStore, record));
                testProjectBugDetailForm.down('#toTrq').toTrq = record.get('id');
            }
        }
    }
});
